package ro.bluecube.admlocal.registruagricol.entity;

public enum Sex {
	Female("Feminin"), Male("Masculin");
	String name;

	private Sex(String s) {
		this.name = s;
	}

	@Override
	public String toString() {
		return name;
	}

	private Integer code;

	Sex(Integer code) {
		this.code = code;
	}

	public static Sex fromInteger(Integer code) {
		switch (code.intValue()) {
		case 0:
			return Male;
		case 1:
			return Female;
		default:
			throw new IllegalArgumentException("The code: '" + code
					+ "' is not a valid Sex enum! (valid codes are: 0 .. 3)");
		}
	}

	public Integer toInteger() {
		return code;
	}

	public Integer getCode() {
		return code;
	}
}